package com.syg.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;

@org.springframework.boot.autoconfigure.SpringBootApplication
//在这个注解后面追加(scanBasePackages = "com.syg")<==>@ComponentScan("com.syg")
@ComponentScan("com.syg")//指定扫描包,可以把类放入不同的包中,如果不加,只能放入当前包,这个就是springmvc中在xml文件中开启注解扫描的配置
public class SpringBootApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootApplication.class, args);
    }

    /**
     * 保证可在tomcat容器中运行(必须)
     * <p>
     * 作用是为了支持可以不使用web.xml
     *
     * @param application
     * @return
     */
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootApplication.class);
    }
}
